<script type="text/javascript">
default_perpage = <?=$list_view_pagination[0]?>;

function searchContent(start, per_page) {
	if (per_page == undefined) {
		if ($("#per_page").val()) {
			per_page = $("#per_page").val();
		} else {
			per_page = default_perpage;

		}
	}
	var func_sort = $("#func_sort").val();
	var type_sort = $("#type_sort").val();
	$("#start").val(start);
	
	//ajax load content
	$.post(root + "admincp/" + module + "/ajaxLoadContent", {
		func_order_by : func_sort,
		order_by : type_sort,
		start : start,
		per_page : per_page,
		dateFrom : $("#caledar_from").val(),
		dateTo : $("#caledar_to").val(),
		content : $("#search_content").val(),
		<?php if(!empty($search_filter)) { ?>
		search_filter_<?=$search_filter['name']?>: $('#search_filter_<?=$search_filter['name']?>').val(),
		<?php 
		if(isset($search_filter['sub_filter'])) { ?>
		sub_filter_<?=$search_filter['sub_filter']['name']?>: $('#sub_filter_<?=$search_filter['sub_filter']['name']?>').val(),
		<?php }  }?>
		search_field : $("#search_field").val()
	}, function (data) {
		$("#ajax_loadContent").html(data);
		$(".custom_chk").jqTransCheckBox();
		$(".fancyboxClick").fancybox();
		$(".sort").removeClass("icon_sort_desc");
		$(".sort").removeClass("icon_sort_asc");
		$(".sort").addClass("icon_no_sort");
		if (type_sort == "DESC") {
			$("#" + func_sort).addClass("icon_sort_desc");
		} else {
			$("#" + func_sort).addClass("icon_sort_asc");
		}
		setTimeout("set_width_for_fixed_element()",SET_WIDTH_INTERVAL);
	})
}

function list_pagination(start, per_page)
{

	$.post(root + "admincp/" + module + "/get_pagination_links", {
		start : start,
		per_page : per_page,
	},
	
	function(response){
		$(".pagination").html(response);

	}
	);

}
function updatePagination(start){
	list_pagination(start, $('#per_page').val());
	searchContent(start);
}

<?php if(isset($search_filter['sub_filter'])) { ?>
function ajaxGetFilter(value){
	$.ajax({
		url: root+module+'/ajaxGetFilter',
		type: 'post',
		data: {
		<?php 
		foreach($search_filter['sub_filter'] as $k=>$v) { ?>
			<?=$k?>: '<?=$v?>',
		<?php } ?>
			value: value
		},
		success: function(response){
			$('#sub_filter_<?=$search_filter['sub_filter']['name']?>').html(response);
		}
	});
}
<?php } ?>
</script>
<input type="hidden" value="<?=$this->session->userdata('start')?>" id="start" />
<input type="hidden" value="<?=$list_view_order_name?>" id="func_sort" />
<input type="hidden" value="<?=$list_view_order_direction?>" id="type_sort" />
<div class="gr_perm_error" style="display:none;">
	<p><strong>FAILURE: </strong>Permission Denied.</p>
</div>

<div class="head_table_1">
	<div class="head_title_table"><?=$get_name_module->name?></div>
	<?php 
	if(isset($start)){
		$start=0;
	} else {
		return $start;
	}
	?>
	<div class="footer_table">
		<div class="item_per_page">Items per page:</div>
		<div class="select_per_page">
			<select id="per_page" onchange="searchContent(<?=$start?>,this.value);list_pagination(<?=$start?>, this.value)">
				<?php foreach ($list_view_pagination as $page) {?>
					<option <?php ($per_page==$page) ? print 'selected="selected"' : print '' ?> value="<?=$page?>"><?=$page?></option>
				<?php }?>
			</select>
		</div>
		<div class="pagination"><?=$pagination_links?></div>
	</div>
	<div class="clearAll"></div>
</div>
<div class="head_table_2">
	<div class="head_search">
		<div class="head_search_title">Search Field:</div>
		<div class="head_search_select">
			<select id="search_field">
				<option value="all">Search all fields</option>
				<?php foreach($search_field as $k	=>	$v): ?>
					<option value="<?=$k?>"><?=$v?></option>
				<?php endforeach ?>
			</select>
			
		</div>
		<div class="head_search_input"><input onkeypress="return enterSearch(event)" id="search_content" onclick="if(this.value=='<?=SEARCH_TEXTBOX_MESSAGE?>'){this.value=''}" onblur="if(this.value==''){this.value='<?=SEARCH_TEXTBOX_MESSAGE?>'}" class="input_last" type="text" value="<?=SEARCH_TEXTBOX_MESSAGE?>" /><div onclick="searchContent(0)" class="bt_search"><img alt="Button search" src="<?=PATH_URL.'static/images/admin/icons/searchSmall.png'?>" /></div></div>
		<!--Ajax search filter-->
		<?php if(!empty($search_filter)) { ?>
		<div class="head_search_select filter">
			Filter
			<select onchange="<?php if(!isset($search_filter['sub_filter'])) echo 'searchContent();'; else  echo'ajaxGetFilter($(this).val());'?>" id="search_filter_<?=$search_filter['name']?>">
				<option value="all"><?=$search_filter['text']?></option>
				<?=$search_filter['list_data'];?>
			</select>
		</div>
		<?php } 
		if(isset( $search_filter['sub_filter'])) {
		?>
		<div class="head_search_select filter">
			Filter
			<select onchange="searchContent()" id="sub_filter_<?=$search_filter['sub_filter']['name']?>">
				<option value="all"><?=$search_filter['sub_filter']['default_parent_text']?></option>
				<?=$search_filter['sub_filter']['list_data']?>
			</select>
		</div>	
		<?php } ?>
		<div class="head_search_title">From:</div>
		<div class="head_search_input"><input onkeypress="return enterSearch(event)" id="caledar_from" type="text" /></div>
		<div class="head_search_title">To:</div>
		<div class="head_search_input"><input onkeypress="return enterSearch(event)" id="caledar_to" type="text" /></div>
		<!--<div class="head_search_title">Content:</div>-->
		
	</div>
</div>
<div id="indexView" class="indexView table-1">
	<div id="ajax_loadContent"><img class="loading" alt="Ajax Loader" src="<?=PATH_URL.'static/images/admin/ajax-loader.gif'?>" /></div>
</div>